<template>
  <div>
    <h1>编辑</h1>
    <table v-for="i in suser1">
      <tr>
        <th>{{ i.name }}
        </th>
        <router-link :to="{name:'add_show_shop'}">添加</router-link>
      </tr>
      <tr>


        <td>名称</td>
        <td>价格</td>
        <td>图片</td>
        <td>操作</td>
      </tr>
      <tr v-for="j in i.shop">

        <td>{{ j.name }}</td>
        <td>{{ j.price }}</td>
        <td><img :src="'http://127.0.0.1:8000'+j.pic" alt="" width="200px"></td>
        <td>
          <button @click="del(j.id)">删除</button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "show_detail",
  data() {
    return {
      suser1: [],
      userid: localStorage.getItem('userid')
    }
  },
  methods: {
    get_suser1() {
      this.$axios.get('suser2/?userid=' + this.userid)
        .then(res => {
          if (res.data.code == 200) {
            this.suser1 = res.data.list

          }
        })

    },
    del(id) {
      this.$axios.delete('suser2/?id=' + id)
        .then(res => {
          if (res.data.code == 200) {
            alert('删除成功')
            this.get_suser1()
          }
        })

    }
  },
  mounted() {
    this.get_suser1()
  }

}
</script>

<style scoped>

</style>
